package main

import (
	"fmt"

	_ "gitee.com/liuxiaowei123/vblog-1.1/app/apps"
	"gitee.com/liuxiaowei123/vblog-1.1/config"
	"gitee.com/liuxiaowei123/vblog-1.1/ioc"
	"github.com/gin-gonic/gin"
)

func main() {
	// 加载配置
	err := config.Loadfromtoml("./etc/etc.toml")
	if err != nil {
		panic(err)
	}

	// 初始化模块
	// userimpl := impl.NewUserServiceImpl()
	// tokenimpl := tkimpl.NewTokenServiceImpl(userimpl)
	// tokenapihandler := api.NewTokenApiHandler(tokenimpl)
	ioc.IocController().Init()
	ioc.IocApiHandler().Init()

	// 添加路由
	r := gin.Default()
	// tokenapihandler.Registry(r.Group("/api/vblog"))
	ioc.IocApiHandler().RouteRegistry(r.Group("/api/vblog"))

	// 启动程序
	Address := fmt.Sprintf("%s:%d", config.C.Api.Apiadress, config.C.Api.Apiport)
	fmt.Println(Address)
	err = r.Run(Address)
	if err != nil {
		panic(err)
	}
}
